/************************************************************************

								Heroes IV
					  Copyright 2001, The 3DO Company

	------------------------------------------------------------------
  						       caravan_set.h

	$Header: $

	$NoKeywords: $

 ************************************************************************/

#ifndef CARAVAN_SET_H_INCLUDED
#define CARAVAN_SET_H_INCLUDED

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <set>
#include "caravan_ptr.h"

class t_adventure_object;
class t_town;

// -------------------------------------------------------------------
// Predicate for sorting caravans by town
// -------------------------------------------------------------------
class t_caravan_sorting_predicate
{
	public:
		bool operator()( t_caravan_ptr const & caravan1, t_caravan_ptr const & caravan2 ) const;
};


// -------------------------------------------------------------------
// A sorted set of caravans
// -------------------------------------------------------------------
class t_caravan_set : public std::multiset< t_caravan_ptr, t_caravan_sorting_predicate >
{
	public:
		// "Inherit" std::multiset constructors
		explicit t_caravan_set( const t_caravan_sorting_predicate& comp = t_caravan_sorting_predicate(), const allocator_type& al = allocator_type() );
		t_caravan_set( std::multiset< t_caravan_ptr, t_caravan_sorting_predicate > const & x );
		t_caravan_set( const value_type *first, const value_type *last, const t_caravan_sorting_predicate& comp = t_caravan_sorting_predicate(), const allocator_type& al = allocator_type());

		iterator get_lower_bound_of_destination( t_town * destination );
		const_iterator get_lower_bound_of_destination( t_town * destination ) const;
};

// -------------------------------------------------------------------
// Inline constructors
// -------------------------------------------------------------------
inline t_caravan_set::t_caravan_set( const t_caravan_sorting_predicate& comp, const allocator_type& al )
	: std::multiset< t_caravan_ptr, t_caravan_sorting_predicate >( comp, al )
{
}

inline t_caravan_set::t_caravan_set( std::multiset< t_caravan_ptr, t_caravan_sorting_predicate > const & x )
	: std::multiset< t_caravan_ptr, t_caravan_sorting_predicate >( x )
{
}

inline t_caravan_set::t_caravan_set( const value_type *first, const value_type *last, const t_caravan_sorting_predicate& comp, const allocator_type& al )
	: std::multiset< t_caravan_ptr, t_caravan_sorting_predicate >( first, last, comp, al )
{
}

#endif // CARAVAN_SET_H_INCLUDED

